var e = require("../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../@babel/runtime/regenerator")), a = require("../../@babel/runtime/helpers/asyncToGenerator"), i = e(require("../../http/system")), n = getApp(), s = require("../../http/activityApi.js"), r = new i.default();

Page({
    data: {
        systemInfo: n.data.systemInfo,
        selectedIndex: 0,
        checkBox: !1
    },
    onLoad: function(e) {
        this.loadDetails();
    },
    nothing: function() {},
    itemUseDescOnTap: function(e) {
        var t = e.currentTarget.dataset.index, a = this.data.details.detailList[t];
        this.setData({
            alertInfo: {
                title: "适用商品说明",
                content: a.remark
            }
        });
    },
    useRuleOnTap: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var i;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    if (e.useRuleText) {
                        t.next = 18;
                        break;
                    }
                    return t.prev = 1, n.showLoading(), t.next = 5, r.getSystemConfig("drawNumberActivityRule");

                  case 5:
                    i = t.sent, e.useRuleText = i.data.configValue, e.setData({
                        alertInfo: {
                            title: "使用规则",
                            content: e.useRuleText
                        }
                    }), t.next = 13;
                    break;

                  case 10:
                    t.prev = 10, t.t0 = t.catch(1), console.log(t.t0);

                  case 13:
                    return t.prev = 13, wx.hideLoading(), t.finish(13);

                  case 16:
                    t.next = 19;
                    break;

                  case 18:
                    e.setData({
                        alertInfo: {
                            title: "使用规则",
                            content: e.useRuleText
                        }
                    });

                  case 19:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 1, 10, 13, 16 ] ]);
        }))();
    },
    itemOnTap: function(e) {
        var t = e.currentTarget.dataset.index;
        this.setData({
            selectedIndex: t
        });
    },
    checkBoxOnTap: function() {
        this.setData({
            checkBox: !this.data.checkBox
        });
    },
    buyOnTap: function() {
        if (this.data.checkBox) this.setData({
            buyInfo: this.data.details.detailList[this.data.selectedIndex]
        }); else {
            this.setData({
                scrollIntoView: "checkBox",
                showAgreeTip: !0
            });
            var e = this;
            setTimeout(function() {
                e.setData({
                    showAgreeTip: !1
                });
            }, 2e3);
        }
    },
    ticketBagOnTap: function() {
        this.closePaySuccessDialog(), wx.navigateTo({
            url: "/packages/vip/page/card-ticket-bag/card-ticket-bag"
        });
    },
    closePaySuccessDialog: function() {
        this.setData({
            paySuccess: !1
        });
    },
    onPaySuccess: function() {
        this.setData({
            paySuccess: !0
        });
    },
    loadDetails: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var i, c, u;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, n.showLoading(), t.next = 4, s.drawNumberActivityList();

                  case 4:
                    if (i = t.sent, c = i.data, e.activityId = null, c.length > 0 && (c[0].activityId ? e.activityId = c[0].activityId : c.length > 1 && c[1].activityId && (e.activityId = c[1].activityId)), 
                    e.activityId) {
                        t.next = 11;
                        break;
                    }
                    return n.showAlert("提示", "活动已结束"), t.abrupt("return");

                  case 11:
                    return t.next = 13, s.drawNumberActivityDetails(e.activityId);

                  case 13:
                    return i = t.sent, t.next = 16, r.getServerTime();

                  case 16:
                    u = t.sent, e.setData({
                        details: i.data,
                        isStart: u.data.systemDate > i.data.startTime,
                        startTime: i.data.startTime.substr(0, 16)
                    }), t.next = 23;
                    break;

                  case 20:
                    t.prev = 20, t.t0 = t.catch(0), console.log(t.t0);

                  case 23:
                    return t.prev = 23, wx.hideLoading(), t.finish(23);

                  case 26:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 20, 23, 26 ] ]);
        }))();
    },
    onShareAppMessage: function() {
        return {
            title: "『1983抽盒机小程序』抽盒次数",
            path: "/pages/act-draw-number/act-draw-number?shareFrom=" + n.getUsername(),
            imageUrl: "http://newimg.ap1983.com/prod/20211207/8f852f1a8b2e4eceba74e8b0f1dc2cc2.jpg"
        };
    }
});